package com.way.designpatterncodepratice.proxy.other;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author wayleung
 * @description
 * @date 2020-08-12 10:10:27
 */
public class MyInvocationHandler implements InvocationHandler {

    private Object target;

    public MyInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("代理前做点东西");
        Object result = method.invoke(target, args);
        System.out.println("代理后做点东西");
        return result;
    }
}
